package com.china08.yxyapi.repository.db;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.china08.yxyapi.entity.db.lessons.YxyLessonsTopicCatalog;

public interface YxyLessonsTopicCatalogRepository
        extends JpaRepository<YxyLessonsTopicCatalog, String> {

    List<YxyLessonsTopicCatalog> findByPid(int i);

    List<YxyLessonsTopicCatalog> findByPidOrderByOrderNumAsc(String oneId);

    List<YxyLessonsTopicCatalog> findByPidAndSchoolId(String oneId,
            String schoolId);

    List<YxyLessonsTopicCatalog> findByPidAndLevel(String id1, int i);

    @Query(value = "SELECT * FROM yxy_lessons.yxy_lessons_topic_catalog WHERE pid =?1 AND level =?2 GROUP BY NAME", nativeQuery = true)
    List<YxyLessonsTopicCatalog> findDistinctNameByPidAndLevel(String twoId,
            int i);

    YxyLessonsTopicCatalog findByid(String catalogId3);

    YxyLessonsTopicCatalog findById(String id);

    @Query(value = "select t from YxyLessonsTopicCatalog t where t.level = ?1 and t.pid = ?2")
    List<YxyLessonsTopicCatalog> findByLevelAndPid(int i, String pid);

    @Query(value = "select   * from  yxy_lessons.yxy_lessons_topic_catalog where level = ? order by order_num asc,  last_modified_date desc", nativeQuery = true)
    List<YxyLessonsTopicCatalog> findByLevel1(int i);

    @Query(value = "select  * from  yxy_lessons.yxy_lessons_topic_catalog where pid = ?   and level = ? order by order_num asc,  last_modified_date desc ", nativeQuery = true)
    List<YxyLessonsTopicCatalog> findByPidAndLevel1(String id1, int i);

    @Query(value = "SELECT * FROM yxy_lessons.yxy_lessons_topic_catalog WHERE  level =?1 order by order_num asc,  last_modified_date desc", nativeQuery = true)
    List<YxyLessonsTopicCatalog> findByLevel2(int i);

    @Query(value = "SELECT * FROM yxy_lessons.yxy_lessons_topic_catalog WHERE pid = ?1 and level =?2  order by order_num asc,  last_modified_date desc", nativeQuery = true)
    List<YxyLessonsTopicCatalog> findByPidAndLevel2(String id1, int i);

    List<YxyLessonsTopicCatalog> findByLevel(int i);

    List<YxyLessonsTopicCatalog> findByLevelOrderByOrderNumAsc(int i);
}
